const localStorageFactory = (params) => {
    const { defaultValue, key } = params;
    const getItem = () => {
        return JSON.parse(localStorage.getItem(key) || defaultValue)
    }
    const setItem = (value) => {
        localStorage.setItem(key, JSON.stringify(value || defaultValue))
    }
    const removeItem = () => {
        localStorage.removeItem(key)
    }
    return {
        getItem,
        setItem,
        removeItem
    }
}

export default localStorageFactory